
from flask import Flask
import pymysql

app = Flask(__name__)
CONN = pymysql.connect(host='127.0.0.1', port=3306, user='root', password='123456', db='my_test')


def fetchall(sql):
    cursor = CONN.cursor()
    cursor.execute(sql)
    result = cursor.fetchall()
    CONN.commit()
    cursor.close()
    return result


@app.route('/login')
def login():
    result = fetchall('select * from user')
    return result


@app.route('/index')
def index():
    result = fetchall('select * from user')
    return "result"


if __name__ == '__main__':
    app.run()
# if __name__ == '__main__':
#     data = fetchall('select * from user')
#     print(data)